
package com.ushahidi.android.app;

import java.io.File;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

public class UshahidiPref {
    
    //TODO Oceanmaster Added Static Varibles
    public static final String all = "All";
    public static final String allIncidents = "All Incidents";
    public static final String allResources = "All Resources";
    //public static IncidentMap MainMap=null;
    
    
    public static boolean httpRunning = false;

    public static boolean AutoFetch = false;

    public static boolean vibrate = false;

    public static boolean ringtone = false;

    public static boolean flashLed = false;

    public static int countries = 0;

    public static int AutoUpdateDelay = 0;

    public static final int NOTIFICATION_ID = 1;

    public static final String PREFS_NAME = "UshahidiService";

    public static String incidentsResponse = "";

    //Added by OceanMaster
    public static String incidentCategoriesResponse = "";

    public static String resourceCategoriesResponse = "";
    
    public static String resource_CatgoriesResponse="";//added by yujie store table resource_category
    
    public static String incidentFilterBy = "";
    
    //Added by yujie for retrieve resourceResponse
    public static double NearByRadius=1.5;
    
    public static String resourceResponse = "";
    //TODO the store and retrieve of these fields in Setting and SharedPref
    //Added end
    public static String linkedResourceResponse="";
    // store response linked resource xml 
    
    public static String resourceFilterByID = "";
    
    public static String IncidentID2Link="";  //incident id for link
    
    public static String savePath = "";
    
    public static String periodicalCheckinSwitch="";

    public static final String domain = "http://www.crisisconnection.info/live/";
    
    //public static final String DEFAULT_DOMAIN = "http://www.crisisconnection.info/sandbox/dev/droid";

    public static String firstname = "";

    public static String lastname = "";

    public static String email = "";
    
    public static boolean checkin_switch=true;

    public static String totalReports = "";

    public static String fileName = "";
    
    public static String resourceFileName = "";

    public static int isCheckinEnabled = 0;

    private static SharedPreferences settings;

    private static SharedPreferences.Editor editor;
    
	public  static String Username=null;

    public static void loadSettings(Context context) {
        
	Log.v("Oceanmaster", "UshahidiPref Loaded");
	
	final SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);

        final String path = context.getDir("",
                Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE).toString();

        savePath = settings.getString("savePath", path);
        periodicalCheckinSwitch=settings.getString("PeriodicalCheckInSwitch", "on");
        //domain = settings.getString("Domain", DEFAULT_DOMAIN);
        firstname = settings.getString("Firstname", "");
        lastname = settings.getString("Lastname", "");
        email = settings.getString("Email", "");
        countries = settings.getInt("Countries", 0);
        AutoUpdateDelay = settings.getInt("AutoUpdateDelay", 5);
        AutoFetch = settings.getBoolean("AutoFetch", false);
        totalReports = settings.getString("TotalReports", "100");
        isCheckinEnabled = settings.getInt("CheckinEnabled", isCheckinEnabled);

        // make sure folder exists
        final File dir = new File(UshahidiPref.savePath);
        dir.mkdirs();

    }

    public static void saveSettings(Context context) {
        settings = context.getSharedPreferences(PREFS_NAME, 0);
        editor = settings.edit();
        editor.putInt("CheckinEnabled", isCheckinEnabled);
        editor.commit();
    }
}
